package main

import (
	"fmt"
	"time"
)

var cha = make(chan string)

func main()  {
	go func() {
		defer fmt.Println("子协程调用完毕")

		for i := 0; i < 2; i++ {
			fmt.Println("子协程 ", i)
			time.Sleep(time.Second)
		}
		cha <- "我是子协程，工作完毕"
	}()

	str := <- cha
	fmt.Println(str)
	fmt.Println("子协程工作完毕，主协程退出")
}
